﻿#include "Heap.h"

void check(Heap* heap)
{
	int ret = SmallHeapCheck(&heap, 0, heap->_size);
	printf("%s\n", ret == 1 ? "小根堆" : "不是小根堆");
	for (int i = 0; i < heap->_size; i++)
	{
		printf("%d ", heap->_a[i]);
	}
	printf("\n==========================\n");
}

void test()
{
	int arr[10] = { 3, 8, 2, 6, 1, 9, 4, 7, 5, 0 };
	Heap heap;
	HeapInit(&heap, arr, 10);

	check(&heap);

	HeapPush(&heap, -1);
	HeapPush(&heap, 88);
	HeapPush(&heap, 5);


	while (!HeapEmpty(&heap))
	{
		printf("%d\n", HeapTop(&heap));
		HeapPop(&heap);
	}
}

// 该代码 时间逻辑为小根堆
int main()
{
	test();
	return 0;
}